<!DOCTYPE html>
<html>
 <body>
 
<h1>Wimpy Statistical Calculator</h1>
 
<p>Enter data into the fields below. Blank fields are allowed.</p>
 
 <form name="frm">
<p><input type="text" name="item" id="itemA"></p>
<p><input type="text" name="item" id="itemB"></p>
<p><input type="text" name="item" id="itemC"></p>
<p><input type="text" name="item" id="itemD"></p>
<p><input type="text" name="item" id="itemE"></p>
<p><input type="text" name="item" id="itemF"></p>
<p><input type="text" name="item" id="itemG"></p>
<p><input type="text" name="item" id="itemH"></p>
<p><input type="text" name="item" id="itemI"></p>
<p><input type="text" name="item" id="itemJ"></p>
<p><input type="button" value="Calculate Statistics" onclick="javascript:startSimulation();">
</form>

 
<script>

function startSimulation()
{
	
	var dataSet = new Array();
	var dataSetPos = 0;
	
	if (document.getElementById('itemA').value != "")
		dataSet[dataSetPos++] = parseFloat(document.getElementById('itemA').value);

	if (document.getElementById('itemB').value != "")
		dataSet[dataSetPos++] = parseFloat(document.getElementById('itemB').value);

	if (document.getElementById('itemC').value != "")
		dataSet[dataSetPos++] = parseFloat(document.getElementById('itemC').value);

	if (document.getElementById('itemD').value != "")
		dataSet[dataSetPos++] = parseFloat(document.getElementById('itemD').value);

	if (document.getElementById('itemE').value != "")
		dataSet[dataSetPos++] = parseFloat(document.getElementById('itemE').value);

	if (document.getElementById('itemF').value != "")
		dataSet[dataSetPos++] = parseFloat(document.getElementById('itemF').value);

	if (document.getElementById('itemG').value != "")
		dataSet[dataSetPos++] = parseFloat(document.getElementById('itemG').value);

	if (document.getElementById('itemH').value != "")
		dataSet[dataSetPos++] = parseFloat(document.getElementById('itemH').value);

	if (document.getElementById('itemI').value != "")
		dataSet[dataSetPos++] = parseFloat(document.getElementById('itemI').value);

	if (document.getElementById('itemJ').value != "")
		dataSet[dataSetPos++] = parseFloat(document.getElementById('itemJ').value);
	
	dataSet.sort(function(a,b){return a-b});
	
	document.write("<p>Ordered Data Set: ");
	for (i = 0; i < dataSet.length - 1; i++)
		document.write(dataSet[i] + ", ");
	document.write(dataSet[dataSet.length - 1] + "</p>");
	
	var dataMean = 0;
	for (i = 0; i < dataSet.length; i++)
		dataMean += dataSet[i];
	dataMean /= dataSet.length;
	document.write("<p>Mean: " + dataMean + "</p>");

	document.write("<p>Range: " + (dataSet[dataSet.length - 1] - dataSet[0]) + "</p>");
	
	var sSquare = 0;
	var sampleDev = 0;
	var popDev = 0;
	for (i = 0; i < dataSet.length; i++)
		sSquare += (dataSet[i] - dataMean) * (dataSet[i] - dataMean);
	sampleDev = Math.sqrt(sSquare / (dataSet.length - 1));
	popDev = Math.sqrt(sSquare / (dataSet.length));
	document.write("<p>Sample Variance: " + (sSquare / (dataSet.length - 1)) + "</p>");
	document.write("<p>Sample Standard Deviation: " + sampleDev + "</p>");
	document.write("<p>Population Variance: " + (sSquare / dataSet.length) + "</p>");
	document.write("<p>Population Standard Deviation: " + popDev + "</p>");
	
}


 </script>
 
</body>
 </html> 